﻿
namespace Iterator
{
    internal class BookShelf : IAggregate
    {
        public IIterator Iterator()
        {
            return new BookShelflterator(this);
        }

        private Book[] books;
        private int last = 0;
        public BookShelf(int maxSize)
        {
            this.books = new Book[maxSize];
        }

        public Book GetBookAt(int index)
        {
            return this.books[index];
        }

        public void AppendBook(Book book)
        {
            this.books[last] = book;
            last++;
        }

        public int GetLength()
        {
            return this.books.Length;
        }
    }
}
